package com.zhoug.permission3;

import android.app.AlertDialog;
import android.content.Context;

import java.util.List;
import java.util.Locale;

import androidx.annotation.NonNull;

/**
 * @Author 35574
 * @Date 2021/6/7
 * @Description
 */
class NotAskingPermissionDialog implements INotAskingPermissionDialog {

    @Override
    public void show(Context context, @NonNull List<String> notAskingPermissions, @NonNull Callback callback) {
        String message = String.format(Locale.CANADA, "本应用缺少%s权限\n\n请到设置-应用权限中打开所需权限,否则可能不能正常使用", MUtils.getNames(notAskingPermissions));
        AlertDialog alertDialog = new AlertDialog.Builder(context, R.style.perms_style_permissionDialog)
                .setMessage(message)
                .setPositiveButton("设置", (dialog, which) -> {
                    dialog.dismiss();
                    callback.onConfirm();
                })
                .setNegativeButton("取消", (dialog, which) -> {
                    dialog.dismiss();
                    callback.onCancel();
                })
                .create();
        alertDialog.setCancelable(false);
        alertDialog.show();
    }



}
